//
//  NSString+BoundingRect.m
//  Base
//
//  Created by RazeenCheng on 2017/2/13.
//  Copyright © 2017年 rAGEnchi Giab. All rights reserved.
//

#import "NSString+BoundingRect.h"

@implementation NSString (BoundingRect)

- (CGFloat)boundingHeightWithWidth:(CGFloat)width withFont:(CGFloat)font
{
    return [self boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
                              options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                           attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:font]}
                              context:nil].size.height;
}

- (CGFloat)boundingWidthWithHeight:(CGFloat)height withFont:(CGFloat)font
{
    return [self boundingRectWithSize:CGSizeMake(MAXFLOAT, height)
                              options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                           attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:font]}
                              context:nil].size.width;
}

@end
